import { request } from "@/utils/http"
import { ProvinceItems, ReqGetDepartmentResponse, ReqGetDoctorParams, ReqGetDoctorResponse, ReqGetHospitalDetailResponse, ReqGetHospitalListParams, ReqGetHospitalListResponse, ReqGetScheduleParams, ReqGetScheduleResponse } from "./model/hospitalListTypes";

/**
 * 获取省份的信息
 */
export let reqGetProvince = () => {
  return request.get<any, ProvinceItems>('/admin/cmn/dict/findByDictCode/province');
}

/**
 * 获取城市与区县的信息
 */
export let reqGetCityOrDistrict = (id: React.Key) => {
  return request.get<any, ProvinceItems>('/admin/cmn/dict/findByParentId/' + id);
}

/**
 * 获取医院类型
 */
export let reqGetHosTypes = () => {
  return request.get<any, ProvinceItems>('/admin/cmn/dict/findByDictCode/hostype');
}


/**
 * 获取医院列表
 */
export let reqGetHospitalList = (args: ReqGetHospitalListParams) => {
  //解构赋值  hosname hoscode
  let {page, limit, ...rest} = args;
  return request.get<any, ReqGetHospitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`, {
    params: rest
  })
}


/**
 * 获取医院的所有科室
 */
export let reqGetHospitalDepartments = (hoscode: string) => {
  return request.get<any, ReqGetDepartmentResponse>('/admin/hosp/department/' + hoscode);
}

/**
 * 获取某个医院, 某个科室未来一段时间的排班
 */
export let reqGetHospitalSchedule = ({page, limit, hoscode, depcode}: ReqGetScheduleParams) => {
  return request.get<any, ReqGetScheduleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

/**
 * 获取某个医院, 某个科室, 某一天排班的医生
 */
export let reqGetDoctors = ({workDate, hoscode, depcode}: ReqGetDoctorParams) => {
  return request.get<any, ReqGetDoctorResponse>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}

/**
 * 获取单个医院的详细信息
 */
export let reqGetHospitalDetail = (hosid: string) => {
  return request.get<any, ReqGetHospitalDetailResponse>('/admin/hosp/hospital/show/' + hosid);
}

/**
 * 更新医院的上线状态
 */
export let reqUpdateHospitalStatus = (id: string, status: number) => {
  return request.get(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}